package lambda;

import java.util.function.Function;

public class Demo {

    public static void main(String[] args) {
        try {
            doWork(1L, "ssss", v -> {
                System.out.println("dowork " + v);
                int i = 1/0;
                return "result";
            });
        }catch (Exception e){
            System.out.println("main " + e.getMessage());
        }
    }

    private static <T, R> void doWork(Long id, T data, Function<T, R> op) {
        try {
            System.out.println(id);
            R apply = op.apply(data);
            System.out.println(apply);
        } catch (Exception e) {
            System.out.println("doWork " + e.getMessage());
            throw new RuntimeException(e.getMessage());
        } finally {
            System.out.println("finally ....");
        }
    }
}
